package jap;
import java.awt.Color;

import robocode.*;

public class RoboJuh extends Robot {
	
	public void run() {
		
		while(true) {
			setBodyColor(Color.GREEN);
			setGunColor(Color.ORANGE);
			setScanColor(Color.BLUE);
			setRadarColor(Color.red);
			ahead(100);
			turnGunRight(360);
			back(100);
			turnLeft(90);
			
		}
	}
	
		
	public void onScannedRobot(ScannedRobotEvent e) {
		double dist = e.getDistance();
		if (dist < 200) {
			fireBullet(Rules.MAX_BULLET_POWER);
			setBulletColor(Color.PINK);
			turnGunRight(360);
			fire(3);
			turnLeft(90);
			ahead(50);
		}
		else {
			setBulletColor(Color.RED);
			fire(1);
			ahead(100);
			
			
		}
			
	}

	
	public void onHitByBullet(HitByBulletEvent e) {
		setBodyColor(Color.BLUE);
		turnLeft(90 - e.getBearing());
	    ahead(50);
		
	}
	
	public void onHitWall(HitWallEvent e) {
		setBodyColor(Color.YELLOW);
		turnRight(90);
		ahead(250);
		
	}
	public void onHitRobot(HitRobotEvent e) {
		turnGunRight(360);
		fire(3);
			
	}

	
}
